package com.example.zselasticsearchsf.domain;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import lombok.EqualsAndHashCode;
import org.springframework.data.annotation.Id;
import org.springframework.data.elasticsearch.annotations.DateFormat;
import org.springframework.data.elasticsearch.annotations.Document;
import org.springframework.data.elasticsearch.annotations.Field;
import org.springframework.data.elasticsearch.annotations.FieldType;

import java.io.Serializable;
import java.time.LocalDateTime;

/**
 * @Author: Steven
 * @Date: 2023/5/12 12:05
 * 把返回会话存档的媒体文件上传的minio，然后返回连接 以及会话内容保存在搜索引擎 便于搜索
 * 主要要添加 @Field(name = "xxx")这个注解,
 * 添加@JsonProperty注解是为了向前端返回结果时，由驼峰转换为下划线的形式。
 */
@Data
@EqualsAndHashCode
//@Document(indexName = "ems",type = "emp")
@Document(indexName = "chat_record") //必须指定索引名，否则默认类名 不能大写
public class ChatRecordBusinessData implements Serializable {

    private static final long serialVersionUID = 1796004666410927233L;

    @ApiModelProperty(name = "msgId", value = "消息id，消息的唯一标识，企业可以使用此字段进行消息去重。",dataType = "String")
    @Id //用来将对象中id属性与文档中_id 一一对应 必须有这个注解！！ No id property found for class---。类似mybatis中实体类无主键
    @Field(name = "msg_id")
    private String msgId;

    @ApiModelProperty(name = "action", value = "消息动作，目前有send(发送消息)/recall(撤回消息)/switch(切换企业日志)三种类型。",dataType = "String")
    @Field(name = "action",type = FieldType.Keyword)
    private String action;

    @ApiModelProperty(name = "from", value = "转换后的消息发送方name。转换源同一企业内容为userid，非相同企业为external_userid。消息如果是机器人发出，也为external_userid。",dataType = "String")
    @Field(name = "from",type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String from;

    @ApiModelProperty(name = "toList", value = "消息接收方列表，可能是多个，转换后的消息发送方name。转换源同一个企业内容为userid，非相同企业为external_userid。",dataType = "数组，内容为string类型")

    @Field(name = "to_list",type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String toList;

    @ApiModelProperty(name = "roomName", value = "转换后的群聊消息的群名。如果是单聊则为空。",dataType = "String")
    @Field(name = "room_name",type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String roomName;

    @ApiModelProperty(name = "roomId", value = "转换后的群聊消息的群名。如果是单聊则为空。",dataType = "String")
    @Field(name = "room_id",type = FieldType.Keyword)
    private String roomId;


    @ApiModelProperty(name = "msgTime", value = "转换后的消息发送时间 ",dataType = "LocalDateTime")
    @Field(name = "msg_time",type = FieldType.Date,format = DateFormat.basic_date_time)//FieldType.Date,必须指定format
    @JsonFormat(pattern = "yyyy-MM-dd")
    private LocalDateTime msgTime;


    @ApiModelProperty(name = "msgType",dataType = "String",value = "消息类型",
            notes = "①文本消息为：text。" +
                    "②图片消息为：image。" +
                    "③撤回消息为：revoke。" +
                    "④同意消息为：agree，不同意消息为：disagree。" +
                    "⑤语音消息为：voice。" +
                    "⑥视频消息为：video。" +
                    "⑦名片消息为：card。" +
                    "⑧位置消息为：location。" +
                    "⑨表情消息为：emotion。" +
                    "⑩文件消息为：file。" +
                    "11 链接消息为：link。" +
                    "12 消息为：weapp。")
    @Field(name = "msg_type",type = FieldType.Keyword)
    private String msgType;

   @ApiModelProperty(name = "text", value = "①消息内容",dataType = "String")
   @Field(name = "text_content",type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
   private String textContent;
    @ApiModelProperty(name = "imageLinks", value = "②【转存】后的图片地址S，逗号分隔",dataType = "String",notes = "转存的文件id为:媒体资源的id信息sdkfileid")
    @Field(type = FieldType.Keyword)
    private String imageLinks;

    @ApiModelProperty(name = "revoke", value = "③撤回了一条消息",dataType = "String")

    private String revoke;

    @ApiModelProperty(name = "agree", value = "④通用会话存档",dataType = "String")
    private String agree;

    @ApiModelProperty(name = "disAgree", value = "④拒绝会话存档",dataType = "String")
    @Field(name = "dis_agree",type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String disAgree;

    @ApiModelProperty(name = "voiceLinks", value = "⑤【转存】后的语音片地址S，逗号分隔",dataType = "String",notes = "转存的文件id为:媒体资源的id信息sdkfileid")
    @Field(name = "voice_links",type = FieldType.Keyword)
    private String voiceLinks;


    @ApiModelProperty(name = "voiceLinks", value = "⑥【转存】后的视频片地址S，逗号分隔",dataType = "String",notes = "转存的文件id为:媒体资源的id信息sdkfileid")
    @Field(name = "video_links",type = FieldType.Keyword)
    private String videoLinks;

    @ApiModelProperty(name = "card", value = "⑦名片",dataType = "String",notes = "转存格式为:名片所有者所在的公司名称+名片所有者name" )
    private String card;
    @ApiModelProperty(name = "location", value = "⑧地理位置",dataType = "String",notes = "转存格式为:位置信息的title+地址信息address" )
    private String location;

    @ApiModelProperty(name = "emotion", value = "⑨转存的表情连接",dataType = "String",notes = "表情类型，png或者gif.1表示gif 2表示png。" )
    @Field(name = "emotion_links",type = FieldType.Keyword)
    private String emotionLinks;

    @ApiModelProperty(name = "voiceLinks", value = "⑩【转存】后的文件地址S，逗号分隔",dataType = "String",notes = "转存的文件id为:文件名称filename+文件后缀类型fileext")
    @Field(name = "file_links",type = FieldType.Keyword)
    private String fileLinks;

    @ApiModelProperty(name = "link", value = "11.链接ToSting",dataType = "String")
    private String link;
    @ApiModelProperty(name = "weapp", value = "12.小程序消息ToSting",dataType = "String")
    private String weapp;
//    @ApiModelProperty(name = "chatrecord", value = "13.聊天记录",dataType = "String")
//    private ChatRecord chatrecord;
    private String todo;
    private String vote;
    private String collect;
    private String meetingVoiceCall;
    private String voipId;
    @Field(name = "voip_doc_share_links",type = FieldType.Keyword)
    private String voipDocShareLinks;
    @Field(name = "red_packet",type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String redPacket;
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String meeting;
    @ApiModelProperty(value = "在线文档消息")
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String doc;
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String info;
    //    日程消息
    @Field(type = FieldType.Text,analyzer = "ik_max_word",searchAnalyzer = "ik_smart")
    private String calendar;

    //    视频号消息
    private String sphfeed;

   /*   // 混合消息内容。可包含图片、文字、表情等多种消息。Object类型
    private Mixed mixed;
  @Data
    @EqualsAndHashCode
//    注：mixed内包含一个item数组，其中每个元素由type与content组成，
//    type和content均为String类型。JSON解析content后即可获取对应type类型的消息内容。
    public static class Mixed {
        private List<MixedItem> item;
    }

    @Data
    @EqualsAndHashCode
    public static class MixedItem {
        private String type;
        private String content;
    }

    @Data
    @EqualsAndHashCode
    public static class ChatRecord {
        @ApiModelProperty(value = "聊天记录标题", dataType = "String")
        private String title;

        @ApiModelProperty(value = "消息记录内的消息内容，批量数据", dataType = "String")
        private List<ChatRecordItem> item;

    }


    @Data
    @EqualsAndHashCode
    public static class ChatRecordItem {
        @ApiModelProperty(value = "聊天记录标题", dataType = "String", notes = "每条聊天记录的具体消息类型：ChatRecordText/ ChatRecordFile/ ChatRecordImage/ ChatRecordVideo/ ChatRecordLink/ ChatRecordLocation/ ChatRecordMixed ")
        private String type;
        @ApiModelProperty(value = "消息时间，utc时间，单位秒", dataType = "Sting")
        private String msgtime;
        @ApiModelProperty(value = "消息内容。Json串，内容为对应类型的json。", dataType = "String")
        private String content;
        @ApiModelProperty(value = "是否来自群会话", dataType = "Bool")
        private boolean from_chatroom;
    }*/
}
